package com.itcast.demo1;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class C3P0test {
    public static void main(String[] args) throws Exception{
        DataSource dataSource = new ComboPooledDataSource();
        Connection con = dataSource.getConnection();
        String sql = "select * from t_student";
        PreparedStatement preparedStatement = con.prepareStatement(sql);
        ResultSet resultSet = preparedStatement.executeQuery();
        while(resultSet.next()){
            System.out.println(resultSet.getInt("id") + "," + resultSet.getString("name") + "," + resultSet.getInt("age"));

        }
        con.close();
        preparedStatement.close();
        resultSet.close();
    }

}
